﻿using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.Linq;
using System.ServiceModel.DomainServices.Server;
using System.Web;

namespace Candy.Web.Data
{
    public class FamilyDto
    {
        [Key]
        public int Id { get; set; }

        public int? ParentId { get; set; }

        [Required]
        public int ProjectId { get; set; }

        [StringLength(50, MinimumLength = 3, ErrorMessage = "A project name should be at least 3 characters long but not longer than 50 character.")]
        [RegularExpression(@"^[0-9A-Za-z]+[0-9A-Za-z/]*[0-9A-Za-z]+$", ErrorMessage = "Name should only contain characters and numbers.")]
        [Required]
        public string Name { get; set; }

        [Required]
        [Editable(false, AllowInitialValue = true)]
        public DateTime CreateDate { get; set; }

        [Editable(false, AllowInitialValue = true)]
        public string CreatedBy { get; set; }

        [Required]
        public FamilyType Type { get; set; }


        [Include]
        [Association("subfamilies", "Id", "ParentId")]
        public List<FamilyDto> SubFamilies { get; set; }

        [Include]
        [Association("items", "Id", "FamilyId")]
        public List<GeneDto> Items { get; set; }

        [Include]
        [Association("phylogenies", "Id", "FamilyId")]
        public List<PhylogenyDto> Phylogenies { get; set; }

    }
}